package gui.applets;

import java.applet.Applet;
import java.awt.Button;
import java.awt.Event;
import java.awt.Label;
import java.awt.TextField;

public class AppletLabel extends Applet {
	TextField tf = new TextField("tf", 10);
	Label lab1 = new Label("TextField tf");
	Label lab2 = new Label("Label,Left");
	Label lab3 = new Label("Label.RIGHT");
	Button btn1 = new Button("Test 1");
	Button btn2 = new Button("Test 2");

	public void init() {
		this.add(lab1);
		this.add(tf);
		this.add(btn1);
		this.add(lab2);
		this.add(btn2);
		this.add(lab3);
	}

	public boolean action(Event evt,Object obj){
		if(evt.target.equals(btn1)){
			lab1.setText("Text set info Label");
		}else if(evt.target.equals(btn2)){
			if(lab3.getText().trim().length()==0){
				lab3.setText("lab3");
			}
			if(lab3.getAlignment()==Label.LEFT){
				lab3.setAlignment(Label.CENTER);				
			}else
			if(lab3.getAlignment()==Label.CENTER){
				lab3.setAlignment(Label.RIGHT);
			}else
			if(lab3.getAlignment()==Label.RIGHT){
				lab3.setAlignment(Label.LEFT);
			}
		}
		else
			return super.action(evt, obj);
		return false;
	}
}
